package com.xiaochong.tir.api.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.xc.logclient.utils.LogTrace;
import com.xiaochong.service.common.config.oss.OSSTool;
import com.xiaochong.service.common.config.redis.RedisServer;
import com.xiaochong.tir.api.service.BtUserInfoService;
import com.xiaochong.tir.api.service.BtUserService;
import com.xiaochong.tir.api.service.CCountryNumService;
import com.xiaochong.tir.api.userclient.UserServiceClient;
import com.xiaochong.tir.api.util.ApiVersion;
import com.xiaochong.tir.common.data.mapper.BtUserInfoMapper;
import com.xiaochong.tir.common.data.mapper.BtUserMapper;
import com.xiaochong.tir.common.data.mapper.CCountryNumMapper;
import com.xiaochong.tir.common.data.po.BtUserInfo;
import com.xiaochong.tir.common.data.po.CCountryNum;
import com.xiaochong.tir.common.data.vo.ApiResultVo;
import com.xiaochong.tir.common.data.vo.BtUser;
import com.xiaochong.tir.common.data.vo.ReturnResult;
import com.xiaochong.tir.common.util.ApiResultCodeUtils;
import com.xiaochong.tir.common.util.RedisKeysUtils;
import io.swagger.annotations.*;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * 通证指数
 * @author MengXiangDong
 */
@RestController
@Api(value = "用户注册登录")
@RequestMapping(value =ApiVersion.API_V1_PREFIX+"/user")
public class UserController {

	@Autowired
	private UserServiceClient userServiceClient;

	@Autowired
	private BtUserService btUserService;

	@Autowired
	private BtUserInfoMapper btUserInfoMapper;

	@Autowired
	private BtUserInfoService btUserInfoService;

	@Autowired
	private BtUserMapper btUserMapper;

	@Autowired
    private OSSTool ossTool;

	@Autowired
	private RedisServer redisServer;

	@Autowired
	private CCountryNumMapper cCountryNumMapper;

	/**
	 * 获取验证码
	 */
	@ApiOperation(value = "获取验证码" , notes = "返回信息如下:code:000000(成功，result中会返回一个验证token,需在请求端保存做下次验证使用),000006(参数错误),100102(手机验证码请求频繁30s),100106(验证码发送失败),000004(密码操作时可能返回，不存在该账户),500000(系统异常情况)")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "countryNum", value = "国别号码 默认+86", required = false, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "account", value = "手机号码/邮箱地址", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "platform", value = "1：挖链APP|| 2：挖链网 || 3:算立方 6:币通指数", required = true, dataType = "Integer", paramType = "query"),
			@ApiImplicitParam(name = "type", value = "验证码类型 1 登录 2 注册 3 找回密码 4 重置密码 5 绑定邮箱 6 绑定手机 7 确定订单验证码", required = true, dataType = "Integer", paramType = "query"),
			@ApiImplicitParam(name = "params", value = "参数可选", required = false, dataType = "String", paramType = "query")
	})
	@PostMapping("reportList")
	public String sendValidCode(@RequestParam(value = "countryNum", required = false) String countryNum,
													   @RequestParam(value = "account", required = true) String account,
													   @RequestParam(value = "platform", required = true) Integer platform,
													   @RequestParam(value = "type", required = true) Integer type,
													   @RequestParam(value = "params", required = false) String params) {
		try {
			LogTrace.info("获取验证码", "开始执行获取验证码接口",account);
			String result=userServiceClient.sendValidCode( countryNum,account,6,type,params  );

			JSONObject jsonObject = JSONObject.parseObject(result);

			if("000000".equals(jsonObject.getString("code"))){
				JSONObject dataObject  =  jsonObject.getJSONObject("data");
				String codeToken = dataObject.getString("result");

				redisServer.set(RedisKeysUtils.WEB_CT+account , codeToken);
				dataObject.put("result" , "webCode");
			}

			return jsonObject.toJSONString();
		}catch (Exception e){
			e.printStackTrace();
			LogTrace.error("获取验证码",e);
		}
		return  null;
	}


	private String getCodeToken(String account ){
		if(StringUtils.isNotBlank(account)){
			return  redisServer.get(RedisKeysUtils.WEB_CT+account);
		}
		return null;
	}
	/**
	 * 注册
	 */
	@ApiOperation(value = "注册" , notes = "返回信息如下:code:000000(成功，result中会返回包含跨系统token的用户信息，该token只保持一天),000006(参数错误),100104(密码验证错误),100108(账户存在),500000(系统异常情况)")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "countryNum", value = "账号为手机的时候取国别号码,默认+86", required = false, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "account", value = "手机号码/邮箱账号", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "password", value = "密码(最少8个字符)", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "code", value = "验证码", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "codeToken", value = "验证Token", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "platform", value = "1：挖链APP|| 2：挖链网 || 3:算立方 6:币通指数", required = true, dataType = "Integer", paramType = "query")
	})

	@PostMapping("userRegister")
	public String userRegister(@RequestParam(value = "countryNum", required = false) String countryNum,
							   @RequestParam(value = "account", required = true) String account,
							   @RequestParam(value = "password", required = true) String password,
							   @RequestParam(value = "code", required = true) String code,
							   @RequestParam(value = "codeToken", required = true) String codeToken,
							   @RequestParam(value = "platform", required = true) Integer platform) {
		try {
			LogTrace.info("注册", "开始执行注册接口",account);
			codeToken = getCodeToken(account);
			String result=userServiceClient.userRegister( countryNum,account,password,code,codeToken,6 );
			JSONObject jsonObject = (JSONObject) JSONObject.parse( result );

			BtUser btUser1 = new BtUser();
			if(account.contains( "@" )){
				btUser1.setEmail( account );
			}else {
				btUser1.setMobile( account );
			}
			List<BtUser> btList = btUserMapper.selectByAccount( btUser1 );

			LogTrace.info( "注册接口","返回", jsonObject.get( "code" )+"="+btList.size());
			if(jsonObject.get( "code" ).equals( "000000" )||(jsonObject.get( "code" ).equals( "100108" )&&btList.size()==0)){
				BtUser btUser = new BtUser();
				if(account.contains( "@" )){
					btUser.setEmail( account );
				}else {
					btUser.setMobile( account );
				}
				btUser.setCountryNum(countryNum);
				btUser.setStatus( 1 );
				btUser.setDeleteFlag( 0 );
				btUser.setCreateTime( new Date(  ) );
				if(jsonObject.containsKey( "data" )){
					JSONObject jsonObject1 = jsonObject.getJSONObject( "data" );
					if(jsonObject1.containsKey( "platform" )){
						btUser.setSource(jsonObject1.getString( "platform" ) );
					}
					if((jsonObject1.containsKey( "createTime" )&&jsonObject1.getString( "createTime" )==null)||!jsonObject1.containsKey( "createTime" )){
						jsonObject1.put( "createTime",btUser.getCreateTime() );
					}
				}

				int btFlag=btUserService.insertSelective( btUser );
				if(btFlag==1){
					BtUserInfo btUserInfo=new BtUserInfo();
					btUserInfo.setUserId( btUser.getId() );
					btUserInfo.setDeleteFlag( 0 );
					btUserInfo.setCreateTime( new Date(  ) );
					btUserInfoService.insertSelective( btUserInfo );
				}
			}
			return jsonObject.toJSONString();
		}catch (Exception e){
			e.printStackTrace();
			LogTrace.error("注册",e);
		}
		return  null;
	}

	/**
	 * 账户密码登录
	 */
	@ApiOperation(value = "账户密码登录" , notes = "返回信息如下:code:000000(成功，result中会返回包含跨系统token的用户信息，该token只保持一天),000006(参数错误),100104(密码验证错误),000004(用户不存在),100107(账户存在，但状态不可用),500000(系统异常情况)")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "account", value = "登录账号", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "password", value = "登录密码", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "platform", value = "1：挖链APP|| 2：挖链网 || 3:算立方 6:币通指数", required = true, dataType = "Integer", paramType = "query"),
	})
	@PostMapping("userPwdLogin")
	public String userPwdLogin(@RequestParam(value = "account", required = true) String account,
							   @RequestParam(value = "password", required = true) String password,
							   @RequestParam(value = "platform", required = true) Integer platform) {
		try {
			LogTrace.info("账户密码登录", "开始执行账户密码登录接口",account);

			//检查用户状态
			BtUser btUser = checkUserStatus(account);
			if(btUser!=null && btUser.getStatus()==0){
				JSONObject jsonObject = new JSONObject(  );
				jsonObject.put( "code","100107" );
				return jsonObject.toJSONString();
			}
			String result=userServiceClient.pwdLogin(account,password,6);
			JSONObject jsonObject = (JSONObject) JSONObject.parse( result );
			if(jsonObject.getString("code").equals("000000")) {
				//入库
				if(btUser==null){
					insertUser(account,result);
				}
				//返回信息添加用户名和头像发址
				setImageurl(account,jsonObject);
			}
			return jsonObject.toJSONString();
		}catch (Exception e){
			e.printStackTrace();
			LogTrace.error("账户密码登录",e);
		}
		return  null;
	}


	/**
	 * 注销登录
	 */
	@ApiOperation(value = "注销登录" , notes = "000000(成功，result中会返回包含跨系统token的用户信息，并刷新该token时效)")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "userToken", value = "userToken", required = true, dataType = "String", paramType = "query"),
	})
	@PostMapping("logoutUserToken")
	public String logoutUserToken(@RequestParam(value = "userToken", required = true) String userToken) {
		try {
			LogTrace.info("注销登录", "开始执行注销登录接口",userToken);
			String result=userServiceClient.logoutUserToken(userToken);
			//删除缓存中的用户token
			redisServer.remove( RedisKeysUtils.TIR_USER_TOKEN+userToken );
			return result;
		}catch (Exception e){
			e.printStackTrace();
			LogTrace.error("注销登录",e);
		}
		return  null;
	}

	/**
	 * 短信验证码登录
	 */
	@ApiOperation(value = "短信验证码登录" , notes = "返回信息如下:code:000000(成功，result中会返回包含跨系统token的用户信息，该token只保持一天),000006(参数错误),100101(手机验证码错误),000004(用户不存在),100107(账户存在，但状态不可用),500000(系统异常情况)")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "countryNum", value = "国别号码,默认+86", required = false, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "phone", value = "手机号码", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "code", value = "验证码", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "codeToken", value = "请求验证码返回的Token", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "platform", value = "1：挖链APP|| 2：挖链网 || 3:算立方 6:币通指数", required = true, dataType = "Integer", paramType = "query"),
	})
	@PostMapping("validCodeLogin")
	public String validCodeLogin(@RequestParam(value = "countryNum", required = false) String countryNum,
								 @RequestParam(value = "phone", required = true) String phone,
								 @RequestParam(value = "code", required = true) String code,
								 @RequestParam(value = "codeToken", required = true) String codeToken,
								 @RequestParam(value = "platform", required = true) Integer platform) {
		try {
			LogTrace.info("短信验证码登录", "开始执行短信验证码登录接口",phone);
			//检查用户状态
			BtUser btUser = checkUserStatus(phone);
			if(btUser!=null && btUser.getStatus()==0){
				JSONObject jsonObject = new JSONObject(  );
				jsonObject.put( "code","100107" );
				return jsonObject.toJSONString();
			}
			codeToken = getCodeToken(phone);
			String result=userServiceClient.validCodeLogin(countryNum,phone,code,codeToken,6);
			JSONObject jsonObject = (JSONObject) JSONObject.parse( result );
			if(jsonObject.getString("code").equals("000000")) {
				//入库
				if(btUser==null){
					insertUser(phone,result);
				}
				//返回信息添加用户名和头像发址
				setImageurl(phone,jsonObject);
			}
			return jsonObject.toJSONString();
		}catch (Exception e){
			e.printStackTrace();
			LogTrace.error("短信验证码登录",e);
		}
		return  null;
	}

	/**
	 * 修改用户密码
	 */
	@ApiOperation(value = "修改用户密码" , notes = "返回信息如下:code:000000(成功，result中会返回包含跨系统token的用户信息，该token只保持一天),000006(参数错误),100101(手机验证码错误),000004(用户不存在),100107(账户存在，但状态不可用),500000(系统异常情况)")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "account", value = "手机号码/邮箱账号", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "password", value = "密码(最少8个字符)", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "code", value = "验证码", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "codeToken", value = "验证Token", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "platform", value = "1：挖链APP|| 2：挖链网 || 3:算立方 6:币通指数", required = true, dataType = "Integer", paramType = "query"),
	})
	@PostMapping("updateUserPwd")
	public String updateUserPwd(@RequestParam(value = "account", required = true) String account,
								@RequestParam(value = "password", required = true) String password,
								@RequestParam(value = "code", required = true) String code,
								@RequestParam(value = "codeToken", required = true) String codeToken,
								@RequestParam(value = "platform", required = true) Integer platform) {
		try {
			LogTrace.info("修改用户密码", "开始执行修改用户密码接口",account);
			codeToken = getCodeToken(account);
			String result=userServiceClient.updateUserPwd( account,password,code,codeToken,6 );
		
			return result;
		}catch (Exception e){
			e.printStackTrace();
			LogTrace.error("修改用户密码",e);
		}
		return  null;
	}


	/**
	 * 根据老密码修改成新密码
	 */
	@ApiOperation(value = "根据老密码修改成新密码" , notes = "000000(成功),000006(参数错误),000003(更新失败),000004(账户不存在),100104(密码错误),500000(系统异常情况)")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "account", value = "手机号码/邮箱账号", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "password", value = "旧密码(最少8个字符)", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "newPassword", value = "新密码(最少8个字符)", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "code", value = "验证码", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "codeToken", value = "验证Token", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "platform", value = "1：挖链APP|| 2：挖链网 || 3:算立方 6:币通指数", required = true, dataType = "Integer", paramType = "query"),
	})
	@PostMapping("updateUserPwdByOldPwd")
	public String updateUserPwdByOldPwd(@RequestParam(value = "account", required = true) String account,
										@RequestParam(value = "password", required = true) String password,
										@RequestParam(value = "newPassword", required = true) String newPassword,
										@RequestParam(value = "code", required = true) String code,
										@RequestParam(value = "codeToken", required = true) String codeToken,
										@RequestParam(value = "platform", required = true) Integer platform) {
		try {
			LogTrace.info("根据老密码修改成新密码", "开始执行根据老密码修改成新密码接口",account);

			codeToken = getCodeToken(account);
			String result=userServiceClient.updateUserPwdByOldPwd( account,password,newPassword,code,codeToken,6 );
			//入库
			insertUser(account,result);
			return result;
		}catch (Exception e){
			e.printStackTrace();
			LogTrace.error("根据老密码修改成新密码",e);
		}
		return  null;
	}

	/**
	 * 更改用户昵称
	 */
	@ApiOperation(value = "更改用户昵称" , notes = "000000(成功),000006(参数错误),000003(更新失败),000004(账户不存在),500000(系统异常情况)")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "account", value = "手机号/邮箱", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "userName", value = "昵称", required = true, dataType = "String", paramType = "query")
	})
	@PostMapping("renameUser")
	public ApiResultVo renameUser(@RequestParam(value = "account", required = true) String account,
							 @RequestParam(value = "userName", required = true) String userName) {
		LogTrace.info("更改用户昵称", "开始执行更改用户昵称接口",account);

		try {
			ApiResultVo apiResultVo = new ApiResultVo();
			apiResultVo.setTradeId( LogTrace.getTrace().getTraceId() );
			if(account==null || userName==null){
				apiResultVo.setCode( "000006" );
				apiResultVo.setMessage( "参数错误" );
				return apiResultVo;
			}

			BtUser btUser = new BtUser();
			if(account.contains( "@" )){
				btUser.setEmail( account );
			}else{
				btUser.setMobile( account );
			}
			List<BtUser> btList = btUserMapper.selectByAccount( btUser );
			if (btList.size()==0){
				apiResultVo.setCode( "000004" );
				apiResultVo.setMessage( "账户不存在" );
				return apiResultVo;
			}

			BtUserInfo btUserInfo = new BtUserInfo();
			btUserInfo.setMark( account );
			btUserInfo.setUserName( userName );
			btUserInfo.setUpdateTime( new Date(  ) );
			int btFlag = btUserInfoMapper.updateByAccount( btUserInfo );

			if (btFlag==1){
				apiResultVo.setCode( "000000" );
				apiResultVo.setMessage( "成功" );
			}else {
				apiResultVo.setCode( "000003" );
				apiResultVo.setMessage( "更新失败" );
			}
			return apiResultVo;
		}catch (Exception e){
			e.printStackTrace();
			LogTrace.error("更改用户昵称",e);
		}
		return  null;
	}

    /**
     * @Title: uploadFile
     * @Description: TODO(上传文件)
     * @param file
     *            上传文件
     * @return
     */
	@ApiOperation(value = "头像上传" , notes = "头像上传")
    @RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
    @ResponseBody
    public Object uploadFile(@RequestParam(value = "file", required = false) MultipartFile file,
							 @RequestParam(value = "account", required = false) String account) {
        String prefix = "png";
        try {
            if (file.getSize() > 2000000) {
                return new ReturnResult<Object>(-1, "文件太大,请重新选择文件！", null, 0);
            }
            prefix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1);
            String fileName = UUID.randomUUID().toString().replace("-", "") + "." + prefix;

            boolean imgFlag = ossTool.upload(  file.getInputStream(),fileName );
			String imgUrl=null;
			if (imgFlag==true){
				imgUrl=ossTool.getOSSUrl( fileName );
			}
            System.out.println(imgUrl);
            LogTrace.info("上传图片路径","imgurl", imgUrl);

			BtUserInfo btUserInfo = new BtUserInfo();
			btUserInfo.setMark( account );
			btUserInfo.setImageUrl( fileName );
			btUserInfo.setUpdateTime( new Date(  ) );
			int btFlag = btUserInfoMapper.updateByAccount( btUserInfo );

			if(btFlag==1){
				return new ReturnResult<Object>(0, "上传成功！", imgUrl, 0);
			}else{
				return new ReturnResult<Object>(-1, "文件上传失败！", null, 0);
			}

        } catch (Exception e) {
            e.printStackTrace();
            LogTrace.error("上传图片失败：",e);
            LogTrace.error(getClass().getSimpleName()+"/uploadFile", e.getMessage(), e);
            return new ReturnResult<Object>(-1, "文件上传失败！", null, 0);
        }
    }

	/**
	 * 获取国别号
	 */
	@ApiOperation(value = "获取国别号" , notes = "000000(成功),500000(系统异常情况)")
	@PostMapping("countryNums")
	public ApiResultVo countryNums() {
		LogTrace.info("获取国别号", "开始执行获取国别号接口",null);
		ApiResultVo apiResultVo = new ApiResultVo();
		try {
			apiResultVo.setCode( "000000" );
			apiResultVo.setMessage( "成功" );
			CCountryNum cCountryNum = new CCountryNum();
			cCountryNum.setHot( 1 );
			List<CCountryNum> cCountryNumsList = cCountryNumMapper.getAllCountryNums( cCountryNum );
			apiResultVo.setData( cCountryNumsList );
			apiResultVo.setTotal( cCountryNumsList.size() );
			return apiResultVo;
		}catch (Exception e){
			e.printStackTrace();
			LogTrace.error("获取国别号",e);
			apiResultVo.setCode( "500000" );
			apiResultVo.setMessage( "系统异常情况" );
		}
		return  null;
	}

    public int insertUser(String account,String jsonObject){
		int resultFlag=0;
			BtUser btUser1 = new BtUser();
			if(account.contains( "@" )){
				btUser1.setEmail( account );
			}else {
				btUser1.setMobile( account );
			}
			btUser1.setCountryNum("+86");
			btUser1.setStatus( 1 );
			btUser1.setDeleteFlag( 0 );
			btUser1.setCreateTime( new Date(  ) );

			JSONObject jsonObject1 = JSON.parseObject( jsonObject );
			if(jsonObject1.containsKey( "data" )){
				JSONObject jsonObject2 = jsonObject1.getJSONObject( "data" );
				if(jsonObject2.containsKey( "platform" )){
					btUser1.setSource( jsonObject2.getString( "platform" ) );
				}else{
					btUser1.setSource( "6" );
				}
				if(jsonObject2.containsKey("countryNum")){
					btUser1.setCountryNum(jsonObject2.getString("countryNum" ));
				}
			}
			int btFlag=btUserService.insertSelective( btUser1 );
			if(btFlag==1){
				BtUserInfo btUserInfo=new BtUserInfo();
				btUserInfo.setUserId( btUser1.getId() );
				btUserInfo.setDeleteFlag( 0 );
				btUserInfo.setCreateTime( new Date(  ) );
				resultFlag =btUserInfoService.insertSelective( btUserInfo );
			}
		return resultFlag;
	}

	public void setImageurl(String account,JSONObject jsonObject){
		//返回信息添加用户名和头像发址
		BtUser btUser = new BtUser();
		if(account.contains( "@" )){
			btUser.setEmail( account );
		}else {
			btUser.setMobile( account );
		}
		List<BtUser> btList = btUserMapper.selectByAccount( btUser );
		if(btList.size()>0){
			btUser=btList.get( 0 );
			jsonObject.getJSONObject( "data" ).put( "userName", btUser.getUserName() );
			jsonObject.getJSONObject( "data" ).put( "userId", btUser.getId() );
			if(btUser!=null && StringUtils.isNotBlank( btUser.getImageUrl() )){
				String imgUrl=ossTool.getOSSUrl( btUser.getImageUrl() );
				jsonObject.getJSONObject( "data" ).put( "imageUrl", imgUrl );
			}
		}
	}

	public BtUser checkUserStatus(String account){
		BtUser btUser = new BtUser();
		if(account.contains( "@" )){
			btUser.setEmail( account );
		}else {
			btUser.setMobile( account );
		}
		List<BtUser> btList = btUserMapper.selectByAccount( btUser );
		if(btList.size()>0){
			btUser=btList.get( 0 );
			return btUser;
		}
		return null;
	}


	/**
	 * 更改用户昵称
	 */
	@ApiOperation(value = "检查用户账户" , notes = "100108(账号已存在),000004(数据不存在)")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "account", value = "手机号/邮箱", required = true, dataType = "String", paramType = "query")
	})
	@PostMapping("checkAccount")
	public ApiResultVo checkAccount(@RequestParam(value = "account", required = true) String account) {
		LogTrace.info("检查用户账户", "开始执行检查用户账户接口",account);
		try {
			ApiResultVo apiResultVo = new ApiResultVo();
			apiResultVo.setTradeId( LogTrace.getTrace().getTraceId() );
			String result = userServiceClient.checkAccount( account );
			apiResultVo.setData( result );
			return apiResultVo;
		}catch (Exception e){
			e.printStackTrace();
			LogTrace.error("检查用户账户",e);
		}
		return  null;
	}




}
